#ifndef APPEVENT_H
#define APPEVENT_H

#include <QObject>
#include <QTreeWidgetItem>
#include "Geo/geometry/geogeometry.h"
#include "Geo/map/geofielddefn.h"
class GeoFeatureLayer;
class GeoRasterLayer;
class GeoLayer;
class GeoFeature;

enum DBTreeNodeType
{
    mysqlRoot=1001,
    databaseName,
    featureGroup,
    schemeGroup,
    FLayerPoint,
    FLayerLine,
    FLayerPolygon,
    Table,
};

enum DBTreeColNum
{
    colItem=0,
    colItemType=1
};

class AppEvent : public QObject
{
    Q_OBJECT
public:
    static AppEvent* getInstance();

signals:
    void sigSetDarkTheme();
    void sigSetLightTheme();
    void sigNewMap(const QString& name, const QString& path);
    void sigUpdateOpengl();

    void sigUpdateProTable(GeoLayer*layer);

    void sigAddNewLayerToLayersTree(GeoLayer* layer);
    void sigSendMapToGPU(bool bUpdate = true);
    void sigSendLayerToGPU(GeoLayer* layer, bool bUpdate = true);
    void sigSendFeatureToGPU(GeoFeature* feature);
    void sigZoomToMap();
    void sigZoomToLayer(GeoLayer* layer);
    void sigUpdateCoord(double geoX, double geoY);
    void sigStartEditing(bool on);
    void sigUpdateCursorType();
    void sigDeleteFeatures(bool softDelete);

    void sigUpdateDBTreeWidget(const QString &root,QTreeWidgetItem *context);
    void sigAddNewSQLFLayer(const QString &layerName,GeometryType geomType);

    void sigAddField(QString fieldName, GeoFieldType fieldType);
    void sigDeleteField(int fieldIndex);
    void sigAddGDBData(QString GDBName);
    void sigAddColorTreeBlock(GeoFeatureLayer* layer,QVector<QString> labels,QVector<QColor> colors);
public slots:
    void onSetDarkTheme();
    void onSetLightTheme();
    void onNewMap(const QString& name, const QString& path);
    void onUpdateOpengl();
    void onUpdateProTable(GeoLayer* layer);
    void onAddNewLayerToLayersTree(GeoLayer* layer);
    void onSendMapToGPU(bool bUpdate = true);
    void onSendLayerToGPU(GeoLayer* layer, bool bUpdate = true);
    void onSendFeatureToGPU(GeoFeature* feature);
    void onZoomToMap();
    void onZoomToLayer(GeoLayer* layer);
    void onUpdateCoord(double geoX, double geoY);
    void onStartEditing(bool on);
    void onUpdateCursorType();
    void onDeleteFeatures(bool softDelete);

    void on_UpdateDBTreeWidget(const QString &root,QTreeWidgetItem *context);
    void on_AddNewSQLFLayer(const QString &layerName,GeometryType geomType);
    void on_AddField(const QString &fieldName, GeoFieldType fieldType);
    void on_DeleteField(int fieldIndex);
    void on_AddGDBData(QString GDBName);
    void on_AddColorTreeBlock(GeoFeatureLayer* layer,QVector<QString> labels,QVector<QColor> colors);

private:
    explicit AppEvent(QObject *parent = nullptr);
    static AppEvent* pInstance;
};

#endif // APPEVENT_H
